package com.example.admin.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.example.admin.mapper.PersonMapper;
import com.example.admin.model.Example;
import com.example.admin.model.Person;
import com.example.admin.result.ResponseResult;
import com.example.admin.service.TemplateService;
import com.example.admin.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TemplateServiceImpl implements TemplateService {

    private static final Logger logger = LoggerFactory.getLogger(TemplateServiceImpl.class);

    @Resource
    PersonMapper personMapper;

    @Override
    public ResponseResult<Map<String, List<Person>>> queryPersonTemplate() {
        List<Person> list = personMapper.queryPersonTemplate();
        Map<String, List<Person>> map = new HashMap<>();
        map.put("list", list);
        map.put("list", list);
        String string = JSON.toJSONString(ResponseResult.succeed("00000", "操作成功", map, list.size()), SerializerFeature.WriteMapNullValue);
        ResponseResult<Object> responseResult = ResultUtil.resultObject(string);
        logger.info("出参：{}", JSON.toJSONString(responseResult, SerializerFeature.WriteMapNullValue));
        ResultUtil.resultDataMap(string, Person.class);
        return ResultUtil.resultMap(string, Person.class);
    }
}